package com.cyan.app.workflow.activity.LGS;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.Spinner;
import android.widget.TextView;

import com.cyan.app.barcode.CaptureActivity;
import com.cyan.app.workflow.R;
import com.cyan.app.workflow.activity.Common.PurvdaActivity;
import com.cyan.app.workflow.base.activity.BaseActivity;
import com.cyan.app.workflow.bean.CommonBean;
import com.cyan.app.workflow.bean.DelPoolListBean;
import com.cyan.app.workflow.common.HttpConfig;
import com.cyan.app.workflow.customview.ShowTipDialog;
import com.cyan.app.workflow.util.AppUtils;
import com.cyan.app.workflow.util.network.GetRequestParams;
import com.cyan.app.workflow.widget.PullToRefresh.PullToRefreshBase;
import com.cyan.app.workflow.widget.PullToRefresh.PullToRefreshListView;
import com.google.gson.Gson;

import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by DXW on 2017-07-18.
 */

public class DelzjActivity extends BaseActivity {
    private TextView mTitleName;
    private Button mTitleSeach;
    private View mTitleView;
    private PullToRefreshListView mPullToRefreshExpandableListView;
    private PullToRefreshListView mPullToRefreshNoDataListView;
    private ListView mPoolShowListView;
    private static final int REFRESH_VIEW = 1;               //加载界面
    private static final int REFRESH_SEACH = 2;              //查询
    private static final int REFRESH_REFLESH = 3;            //刷新
    private static final int REFRESH_WASTE = 4;              //作废
    private PopupWindow mPopWindow;

    private DelzjAdapter mPoolShowListViewAdapter;
    private List<DelPoolListBean.DelpoolBean> resultList;
    private static final String VDRNO = "DEL_ZJ_VDRNO";
    private static final String TYPE = "DEL_ZJ_TYPE";
    private static final String STATUS = "DEL_ZJ_STATUS";
    private ShowTipDialog showdialog = new ShowTipDialog();

    private EditText mEditTextDelno;
    private EditText mEditTextVdrno;
    private Spinner mSpinnerStatus;
    private Spinner mSpinnerDeltype;
    private EditText mEditTextItnbr;
    private EditText mEditTextItdsc;
    private String[] statusArr={"待检","已检"};
    private String[] typeArr={"全部","采购","外协"};
    private ArrayAdapter<String> adapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.lgs_del_zj);
        titleBar();
        initView();
        mHandler.sendEmptyMessage(REFRESH_VIEW);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if(requestCode == 0x0001 && resultCode == RESULT_OK){
            String result = "";
            if(data != null) {
                result = data.getStringExtra("result");
            }
            if (!result.contains("60010")) {
                AppUtils.showTip(DelzjActivity.this, "该送货单不存在！");
            }else {
                mEditTextDelno.setText(String.valueOf(result.substring(5)));
            }
            //mEditTextDelno.setText(String.valueOf(result));
        }
        if(requestCode == 0x0002 && resultCode == RESULT_OK){
            String result = "";
            if(data != null) {
                result = data.getStringExtra("result");
            }
            mEditTextVdrno.setText(String.valueOf(result));
        }
        if(requestCode == 0x0003 && resultCode == RESULT_OK){
            String result = "";
            if(data != null) {
                result = data.getStringExtra("poolno");
                for (int i = resultList.size() - 1; i >= 0; i--) {
                    if (resultList.get(i).getPoolno().equals(result)) {
                        resultList.remove(i);
                    }
                }
                refreshPoolListView(resultList);
            }
        }
    }

    @Override
    protected void onStart() {
        super.onStart();
    }

    @Override
    protected void onPause() {
        super.onPause();
        //MobclickAgent.onPause(this);
        //MobclickAgent.onPageEnd("DDActivity");
    }

    @Override
    protected void onResume() {
        super.onResume();
        //MobclickAgent.onResume(this);
        //MobclickAgent.onPageStart("DDActivity");
    }

    @Override
    protected void onStop() {
        super.onStop();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        //DDDataFetcher.getInstance().unRegistPoolsObserver(this);
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
    }

    private Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case REFRESH_VIEW :
                    FetchDataView();
                    break;
                case REFRESH_SEACH:
                    FetchData();
                    break;
                case REFRESH_REFLESH:
                    FetchData();
                    break;
                case  REFRESH_WASTE:
                    new WasteLoader().execute(msg.obj.toString());
                    break;
            }
        }
    };
    private void titleBar() {
        mTitleName = (TextView) findViewById(R.id.top_title_info);
        mTitleName.setText("质检池");
        Button back = (Button) findViewById(R.id.top_title_back);
        back.getBackground().setAlpha(255);// 透明度0~255透明度值 ，值越小越透明
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //返回按钮
                finish();
            }
        });
        mTitleSeach = (Button) findViewById(R.id.top_title_refres_with_icon);
        mTitleSeach.setVisibility(View.INVISIBLE);
        mTitleSeach = (Button) findViewById(R.id.top_title_refres);
        mTitleSeach.setVisibility(View.VISIBLE);
        mTitleSeach.setText("筛选");
        mTitleSeach.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showLiveFilterDialog();
            }
        });
        mTitleView = (View) findViewById(R.id.layout_main_ui_top2_title);
    }
    private void initView() {
        mPullToRefreshNoDataListView = (PullToRefreshListView) findViewById(R.id.no_match_show);
        mPullToRefreshNoDataListView.setVisibility(View.GONE);
        mPullToRefreshNoDataListView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener() {
            @Override
            public void onRefresh() {
                mHandler.sendEmptyMessage(REFRESH_SEACH);
            }
        });
        ListView listView = mPullToRefreshNoDataListView.getRefreshableView();
        listView.setAdapter(mNoDataAdapter);

        mPullToRefreshExpandableListView = (PullToRefreshListView) findViewById(R.id.show_list);
        mPoolShowListView = mPullToRefreshExpandableListView.getRefreshableView();
        mPullToRefreshExpandableListView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener() {
            @Override
            public void onRefresh() {
                mHandler.sendEmptyMessage(REFRESH_SEACH);
            }
        });
        mPoolShowListViewAdapter = new DelzjAdapter(this, new ArrayList<DelPoolListBean.DelpoolBean>());
        mPoolShowListView.setAdapter(mPoolShowListViewAdapter);
        mPullToRefreshNoDataListView.setPullToRefreshEnabled(true);
        mPullToRefreshExpandableListView.setPullToRefreshEnabled(true);
    }
    private void showLiveFilterDialog() {
        LayoutInflater inflater = LayoutInflater.from(this);
        View view = inflater.inflate(R.layout.lgs_del_lzf, null);
        mPopWindow = new PopupWindow(view, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
        view.setFocusable(true);
        view.setFocusableInTouchMode(true);
        //mPopWindow.setBackgroundDrawable(new BitmapDrawable());
        mPopWindow.setFocusable(true);
        mPopWindow.setTouchable(true);
        mPopWindow.setOutsideTouchable(true);
        view.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                mPopWindow.dismiss();
            }
        });
        mPopWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
            }
        });
        mPopWindow.showAsDropDown(mTitleView);
        mEditTextDelno =  (EditText) view.findViewById(R.id.lgs_del_lzf_delno);
        Button mButtonDelno=(Button)view.findViewById(R.id.lgs_del_lzf_delno_sm);
        mButtonDelno.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivityForResult(new Intent(DelzjActivity.this, CaptureActivity.class), 0x0001);
            }
        });
        mEditTextVdrno = (EditText) view.findViewById(R.id.lgs_del_lzf_vdrno);
        final String vdrno = PreferenceManager.getDefaultSharedPreferences(this).getString(VDRNO,null);
        if(vdrno!=null){
            mEditTextVdrno.setText(String.valueOf(vdrno));
        }

        Button  mButtonVdrno = (Button) view.findViewById(R.id.lgs_del_lzf_vdrno_sm);
        mButtonVdrno.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setClass(DelzjActivity.this, PurvdaActivity.class);
                startActivityForResult(intent,0x0002);
            }
        });

        mSpinnerDeltype = (Spinner) view.findViewById(R.id.lgs_del_lzf_type);
        final String type = PreferenceManager.getDefaultSharedPreferences(this).getString(TYPE,null);
        if(type!=null){
            mSpinnerDeltype.setSelection(Integer.valueOf(type));
        }
        mSpinnerStatus = (Spinner) view.findViewById(R.id.lgs_del_lzf_status);
        String[]  data = getResources().getStringArray(R.array.delstatus_zj);
        adapter =new ArrayAdapter<String>(this,android.R.layout.simple_spinner_dropdown_item,data);
        mSpinnerStatus.setAdapter(adapter);
        //LinearLayout ss = (LinearLayout) view.findViewById(R.id.lgs_del_lzf_status_lin);
        //ss.setVisibility(View.GONE);

        mEditTextItnbr = (EditText) view.findViewById(R.id.lgs_del_lzf_itbrn);
        mEditTextItdsc = (EditText) view.findViewById(R.id.lgs_del_lzf_itdsc);

        Button mSubmit = (Button) view.findViewById(R.id.tqm_man_seach_submit);
        //查询事件
        mSubmit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mPopWindow.dismiss();
                if(mEditTextVdrno.getText().toString().isEmpty()&&vdrno!=null){
                    PreferenceManager.getDefaultSharedPreferences(DelzjActivity.this).edit().remove(VDRNO).commit();
                }
                if(!mEditTextVdrno.getText().toString().isEmpty()){
                    PreferenceManager.getDefaultSharedPreferences(DelzjActivity.this).edit().putString(VDRNO,mEditTextVdrno.getText().toString()).commit();
                }
                PreferenceManager.getDefaultSharedPreferences(DelzjActivity.this).edit().putString(TYPE,String.valueOf(mSpinnerDeltype.getSelectedItemId())).commit();
                PreferenceManager.getDefaultSharedPreferences(DelzjActivity.this).edit().putString(STATUS,String.valueOf(mSpinnerStatus.getSelectedItemId())).commit();
                String delno =mEditTextDelno.getText().toString();
                String vdrno =mEditTextVdrno.getText().toString();
                String status = String.valueOf(mSpinnerStatus.getSelectedItem());
                //String status ="送检";
                String type =String.valueOf(mSpinnerDeltype.getSelectedItem());
                String itnbr =mEditTextItnbr.getText().toString();
                String itdsc =mEditTextItdsc.getText().toString();
                DelzjAsyncLoader task = new DelzjAsyncLoader();
                task.execute(delno,vdrno,status,type,itnbr,itdsc);
            }
        });
    }
    //没数据处理
    BaseAdapter mNoDataAdapter = new BaseAdapter() {
        @Override
        public int getCount() {
            return 1;
        }

        @Override
        public Object getItem(int position) {
            return null;
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            if (convertView != null) {
                return convertView;
            }
            convertView = LayoutInflater.from(DelzjActivity.this).inflate(R.layout.layout_main_nodata, null);
            return convertView;
        }
    };

    public class DelzjAsyncLoader extends AsyncTask<String, Integer, String> {

        @Override
        protected void onPreExecute() {
            showdialog.showDialog(DelzjActivity.this);
        }

        @Override
        protected String doInBackground(String... params) {
            String result = null;
            String action ="507"; //查询送货池记录
            try{
                JSONObject param = new JSONObject();
                param.put("delno", params[0]);
                param.put("vdrno", params[1]);
                param.put("status", params[2]);
                param.put("deltype", params[3]);
                param.put("itnbr", params[4]);
                param.put("itdsc", params[5]);
                result= GetRequestParams.getRequestResult(HttpConfig.HTTP_MAIN_SERVER_URL, action, param.toString(), getApplicationContext());
            }catch (Exception e){
                Log.e("error", e.toString());
            }
            return result;
        }
        @Override
        protected void onPostExecute(String s) {
            if (s == null||s.isEmpty()) {
                FetchDataEnd();
                showdialog.closeDialog();
                return;
            }
            DelPoolListBean commonBean = new Gson().fromJson(s, DelPoolListBean.class);
            if (commonBean!=null) {
                resultList = commonBean.getResult();
            }
            FetchDataEnd();
            showdialog.closeDialog();
        }
    }

    //删除，作废
    private class WasteLoader extends AsyncTask<String, Integer, String> {
        @Override
        protected void onPreExecute() {
            showdialog.showDialog(DelzjActivity.this);
        }
        @Override
        protected String doInBackground(String... params) {
            String result = null;
            String action = "60301";
            try {
                JSONObject param = new JSONObject();
                param.put("poolno", params[0]);
                result = GetRequestParams.getRequestResult(HttpConfig.HTTP_MAIN_SERVER_URL, action, param.toString(), getApplicationContext());
            } catch (Exception e) {
                AppUtils.showTip(DelzjActivity.this, "作业异常，" + e.toString());
                Log.e("error", e.toString());
            }
            if (result == null||result.isEmpty()||result.contains("html")) {
                return  null;
            }
            CommonBean commonBean = new Gson().fromJson(result, CommonBean.class);
            if (commonBean!=null&&commonBean.getCode()==1) {
                return params[0];
            }
            return  null;
        }

        @Override
        protected void onPostExecute(String s) {
            if (s == null||s.isEmpty()||s.contains("html")) {
                AppUtils.showTip(DelzjActivity.this,"作业失败，请稍后再试！");
                showdialog.closeDialog();
                return;
            }
            for (int i = resultList.size() - 1; i >= 0; i--) {
                if (resultList.get(i).getPoolno().equals(s)) {
                    resultList.get(i).setStatus(32);
                    resultList.get(i).setStatusname("送检");
                }
            }
            refreshPoolListView(resultList);
            AppUtils.showTip(DelzjActivity.this,"作废成功！");
            showdialog.closeDialog();
        }
    }

    public class DelzjAdapter extends BaseAdapter {
        List<DelPoolListBean.DelpoolBean> mpoolList;
        private LayoutInflater inflater = null;
        private Context context;
        public  DelzjAdapter(Context context, List<DelPoolListBean.DelpoolBean> list) {
            //inflater = LayoutInflater.from(context);
            this.context=context;
            if (list != null) {
                mpoolList = list;
            }
        }

        public void setDatas(List<DelPoolListBean.DelpoolBean> poolList) {
            if (poolList != null) {
                mpoolList = poolList;
            }
        }

        @Override
        public int getCount() {
            // TODO Auto-generated method stub
            return mpoolList == null ? 0 : mpoolList.size();
        }

        @Override
        public Object getItem(int position) {
            // TODO Auto-generated method stub
            return null;
        }

        @Override
        public long getItemId(int position) {
            // TODO Auto-generated method stub
            return position;
        }

        @Override
        public View getView(final int position, View convertView, ViewGroup parent) {
            ViewHolder holder = null;
            if (convertView == null) {
                holder = new ViewHolder();
                //LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
                //layoutParams.gravity = Gravity.CENTER_VERTICAL;
                //LinearLayout layout = new LinearLayout(context);
                //layout.setLayoutParams(layoutParams);
                //layout.setOrientation(LinearLayout.VERTICAL);
                convertView = LayoutInflater.from(context).inflate(R.layout.lgs_del_zjlist,null);
                holder.list_deltype = (TextView) convertView.findViewById(R.id.lgs_del_zjlist_type);
                holder.list_vdrna = (TextView) convertView.findViewById(R.id.lgs_del_zjlist_vdrna);
                holder.list_delno = (TextView) convertView.findViewById(R.id.lgs_del_zjlist_delno);
                holder.list_itnbr = (TextView) convertView.findViewById(R.id.lgs_del_zjlist_itnbr);
                holder.list_itdsc = (TextView) convertView.findViewById(R.id.lgs_del_zjlist_itdsc);
                holder.list_pono = (TextView) convertView.findViewById(R.id.lgs_del_zjlist_pono);
                holder.list_isurgent = (TextView) convertView.findViewById(R.id.lgs_del_zjlist_isurgent);
                holder.list_accqty = (TextView) convertView.findViewById(R.id.lgs_del_zjlist_accqy1);

                holder.list_status = (TextView) convertView.findViewById(R.id.lgs_del_zjlist_status);
                holder.list_username = (TextView) convertView.findViewById(R.id.lgs_del_zjlist_userno);
                holder.list_date = (TextView) convertView.findViewById(R.id.lgs_del_zjlist_date);
                holder.right_layout = convertView.findViewById(R.id.lgs_del_zjlist_right_layout);
                holder.Waste=(TextView)convertView.findViewById(R.id.lgs_del_zjlist_waste);
                holder.list_prossname=(TextView)convertView.findViewById(R.id.lgs_del_zjlist_prossname);
                convertView.setTag(holder);
            } else {
                holder = (ViewHolder) convertView.getTag();
            }
            final DelPoolListBean.DelpoolBean obj = mpoolList.get(position);
            if(obj.getDeltype()==0){
                holder.list_deltype.setText("采购");
                holder.list_deltype.setBackgroundColor(Color.parseColor("#fe5052"));
                holder.list_prossname.setVisibility(View.GONE);
            }else {
                holder.list_deltype.setText("外协");
                holder.list_deltype.setBackgroundColor(Color.parseColor("#3698e6"));
                holder.list_prossname.setVisibility(View.VISIBLE);
                holder.list_prossname.setText(obj.getFprossname());
            }
            String vdrna=obj.getVdrna();
            if(obj.getVdrna().length()>6){
                vdrna=vdrna.substring(0,6);
            }
            holder.list_vdrna.setText(vdrna);
            holder.list_delno.setText(obj.getDelno());
            holder.list_itnbr.setText(obj.getItnbr());
            String itdsc=obj.getItdsc();
            /*if(itdsc.length()>12){
                itdsc=itdsc.substring(0,12);
            }*/
            holder.list_itdsc.setText(itdsc);
            holder.list_pono.setText(obj.getPono());
            if(obj.getStatus()==33){
                if(obj.getResult()==1){
                    holder.list_status.setText(obj.getStatusname()+"-通过");
                }else{
                    holder.list_status.setText(obj.getStatusname()+"-不通过");
                }
            }else {
                holder.list_status.setText(obj.getStatusname());
            }
            /*if(obj.getUrgent().length()>0){
                holder.list_isurgent.setVisibility(View.VISIBLE);
            }else {
                holder.list_isurgent.setVisibility(View.GONE);
            }*/
            if(obj.getUrgent().length()>0){
                holder.list_isurgent.setVisibility(View.VISIBLE);
                if(obj.getUrgent().length()>3){
                    holder.list_isurgent.setText(obj.getUrgent().substring(0,3));
                }else {
                    holder.list_isurgent.setText(obj.getUrgent());
                }
            }
            else
            {
                holder.list_isurgent.setVisibility(View.GONE);
            }
            holder.list_accqty.setText(String.valueOf(obj.getAccqty()).replace(".0",""));

            holder.list_username.setText(obj.getTqmKeyinusername());
            //holder.list_username.setVisibility(View.GONE);
            holder.list_date.setText(obj.getTqmKeyindate());
            holder.right_layout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Bundle bundle = new Bundle();
                    bundle.putSerializable("delpoolDetail", (DelPoolListBean.DelpoolBean) obj);
                    Intent intent = new Intent();
                    if(obj.getStatus()>32){
                        AppUtils.showTip(DelzjActivity.this,"该单据已质检，不能操作。");
                        return;
                    }
                    /*if(obj.getStatus()==31||obj.getStatus()==30) { //送检
                        intent.setClass(DelzjActivity.this, DellzsActivity.class);
                    }else if((obj.getStatus()==33) && obj.getAsswareh()==0) {//下工序
                        intent.setClass(DelzjActivity.this, DellzxActivity.class);
                    }else if(obj.getStatus()==81 || (obj.getStatus()==33&& obj.getAsswareh()==1)) {//入库
                        intent.setClass(DelzjActivity.this, DellzlActivity.class);
                    }
                    else {
                        AppUtils.showTip(DelzjActivity.this,"该单据已结案，不能操作。");
                        return;
                    }*/
                    intent.setClass(DelzjActivity.this, DelzjdActivity.class);
                    intent.putExtras(bundle);
                    startActivityForResult(intent, 0x0003);
                }
            });
            holder.Waste.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if(obj.getStatus()!=33){
                        AppUtils.showTip(DelzjActivity.this,"该单据不能作废。");
                        return;
                    }
                    Message message = new Message();
                    message.what = REFRESH_WASTE;
                    message.obj = obj.getPoolno();
                    mHandler.sendMessage(message);
                }
            });
            return convertView;
        }

        private class ViewHolder {
            TextView list_vdrna;
            TextView list_delno;
            TextView list_deltype;
            TextView list_pono;
            TextView list_itnbr;
            TextView list_itdsc;

            TextView list_isurgent;
            TextView list_accqty;
            TextView list_status;
            TextView list_username;
            TextView list_date;
            View right_layout;
            TextView Waste;
            TextView list_prossname;
        }
    }
    private void FetchData(){
        final String vdrno = PreferenceManager.getDefaultSharedPreferences(this).getString(VDRNO,null);
        final String type = PreferenceManager.getDefaultSharedPreferences(this).getString(TYPE,null);
        //final String status = PreferenceManager.getDefaultSharedPreferences(this).getString(STATUS,null);
        String status ="0";
        new DelzjAsyncLoader().execute("",vdrno==null?"":vdrno,status==null?statusArr[1]:statusArr[Integer.parseInt(status)],type==null?"":typeArr[Integer.parseInt(type)], "","");
    }
    private void FetchDataView(){
        String vdrno = PreferenceManager.getDefaultSharedPreferences(this).getString(VDRNO,null);
        String type = PreferenceManager.getDefaultSharedPreferences(this).getString(TYPE,null);
        //String status = PreferenceManager.getDefaultSharedPreferences(this).getString(STATUS,null);
        String status ="0";

        new DelzjAsyncLoader().execute("",vdrno==null?"":vdrno,statusArr[Integer.parseInt(status)],type==null?"":typeArr[Integer.parseInt(type)], "","");
    }
    private void FetchDataEnd() {
        onRefreshComplete();
        refreshPoolListView(resultList);
    }
    private void onRefreshComplete() {
        if (mPullToRefreshExpandableListView.isRefreshing()) {
            mPullToRefreshExpandableListView.onRefreshComplete();
        }

        if (mPullToRefreshNoDataListView.isRefreshing()) {
            mPullToRefreshNoDataListView.onRefreshComplete();
        }
    }
    //刷新列表
    private void refreshPoolListView(List<DelPoolListBean.DelpoolBean> list) {
        if (list == null) {
            mPullToRefreshNoDataListView.setVisibility(View.VISIBLE);
            mPullToRefreshExpandableListView.setVisibility(View.GONE);
            mNoDataAdapter.notifyDataSetChanged();
            return;
        }

        if (list.size() == 0) {
            mPullToRefreshNoDataListView.setVisibility(View.VISIBLE);
            mPullToRefreshExpandableListView.setVisibility(View.GONE);
            mNoDataAdapter.notifyDataSetChanged();
            return;
        }
        mPullToRefreshNoDataListView.setVisibility(View.GONE);
        mPullToRefreshExpandableListView.setVisibility(View.VISIBLE);

        DelzjAdapter adapter = new DelzjAdapter(this,null);
        mPoolShowListView.setAdapter(adapter);
        adapter.setDatas(list);
        adapter.notifyDataSetChanged();
    }
}
